package com.meatball.iot.driver.doormagnet.data.document

import cn.hutool.core.date.DateTime
import cn.hutool.core.date.DateUtil
import com.meatball.iot.driver.doormagnet.enums.*
import org.springframework.data.mongodb.core.mapping.Document

/**
 * TODO 门磁实体
 *
 * @property dataStreamId 数据点id
 * @property deviceId 设备ID
 * @property deviceName 设备类型(室内/室外)
 * @property imei 设备IMEI
 * @property productId 产品id
 * @property time 上报时间，时间戳
 * @property datetime ISO时间
 * @property alarmLocation 报警设备
 * @property alarmStatus 报警状态
 * @property eventType 事件类型
 * @property batteryVoltage 电压
 *      如6E,十进制为110,表示110+180=290,即2.90V
 * @property temperature 温度
 *      如15,十进制为21,表示21°C
 * @property receivePower 接收功率
 *      参考信号功率值 >43,信号强;；(35,43],信号中；<35,信号弱；255,无信号
 */
@Document("DOOR_MAGNET")
data class DoorMagnetDocument(
    val dataStreamId: String?,
    val deviceId: String,
    val deviceName: String,
    val imei: String,
    val productId: String,
    val time: Long,
    val datetime: String = DateUtil.formatDateTime(DateTime(time)),
//    val alarmLocation: List<AlarmLocation>,
//    val alarmStatus: Boolean = alarmLocation.isNotEmpty(),
//    val eventType: EventType,
    val state: State? = null,
    val messageType: Cmd,
    val eventType: Event? = null,
    val batteryVoltage: Double,
//    val temperature: Int? = null,
    val receivePower: Int,
    val rawData: String
)
